/**
 *******************************************************************************
 * @FileName  : complier.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-09-10
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#ifndef COMPLIER_H
#define COMPLIER_H

/**
 * GCC code optimization.
 *
 * - Complier cmd line parameter: -ffunction-sections -fdata-sections
 * - Linker cmd line parameter: --gc-sections
 */

#ifndef EXTERN
#define EXTERN            extern
#endif

#define WEAK              __attribute__((weak))
#define ALIGN(x)          __attribute__((aligned(x)))
#define SECTION(x)        __attribute__((section(x)))

#ifndef RAM_CODE
#define RAM_CODE          __attribute__(( section(".ram_code") ))
#endif

#ifndef RETENTION_DATA
#define RETENTION         __attribute__(( section(".retention_data") ))
#endif

#ifndef NOINLINE
#define NOINLINE          __attribute__((noinline))
#endif

#ifndef _inline_
#define _inline_          inline __attribute__((always_inline))
#endif


#define DECLARE_SECTION_INFO(s)				   \
extern char __##s##_start[], __##s##_end[], __##s##_lma[]; \
extern unsigned __##s##_size

#define LMA(s) __##s##_lma
#define VMA(s) __##s##_start
#define SSIZE(s) (__##s##_end - __##s##_start)

DECLARE_SECTION_INFO(ram_code);
DECLARE_SECTION_INFO(data);
DECLARE_SECTION_INFO(bss);
DECLARE_SECTION_INFO(cache);

#endif
